#!/bin/bash
# linux 下交叉编译 thmar(esp32)
# author guyadong
# date 2024/08/23

sh_folder=$(cd "$(dirname $0)"; pwd -P)

CC=xtensa-esp32-elf-gcc
[ -n "$CROSS_COMPILER_PREFIX" ] && CC=$CROSS_COMPILER_PREFIX/bin/$CC

[ ! $($CC -dumpmachine) ] \
    && echo "not install compiler xtensa-esp32-elf-gcc,install please" \
    && exit 255

if ! which cmake 2>/dev/null 
then
    echo cmake NOT FOUND. && exit 255 
fi
if ! which conan 2>/dev/null 
then 
    echo conan NOT FOUND. && exit 255
fi
if  ! python --version 2>/dev/null | grep "Python 3." 
then
    echo Python 3 required. && exit 255
fi

# 指定工具链文件,
conan create . -pr:h conan2/profiles/esp32_gcc -pr:b default \
	--build missing --build thmar \
	--test-folder "" || exit

# -pr:h esp32_gcc 指定目标平台的profile
# -pr:b default  指定编译平台的profile
# --build missing 编译缺少的依赖库
# --build thmar 强制编译thmar
# --test-folder "" 跳过测试

